<template>
  <div class="nav-bar">
    <div class="left">
      <slot name="left"><img src="~assets/images/left.png" alt="back" @click="goback()" /></slot>
    </div>
    <div class="center">
      <slot>EWShop商城</slot>
    </div>
    <div class="right">
      <slot name="right"></slot>
    </div>
  </div>
</template>

<script>
import {useRouter} from 'vue-router'
export default {
  name: "NavBar",
  setup() {
    const router = useRouter()
    const goback = () => router.go(-1)
    return {
      goback
    }
  }
}
</script>

<style scoped lang="scss">
.nav-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 45px;
  z-index: 99;
  background: var(--color-tint);
  color: #fff;
  display: flex;
  align-items: center;
  box-shadow: 0 2px 0 rgba(100, 100, 100, 0.1);
  .left, .right {
    flex-basis: 60px;
    img {
      width: 20px;
      margin-top: 2px;
    }
  }
  .center {
    flex: 1;
  }
}
</style>